<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组every</title>
</head>

<body>
    <script>
        /**
         * 
         * 数组every检测数组中是否所有元素都符合条件，不影响原数组，返回值为Boolean类型
          
         */

        const isBelowThreshold = (currentValue) => currentValue < 40;
        const array1 = [1, 30, 39, 29, 10, 13];
        console.log(array1.every(isBelowThreshold)); // true

        // 检查一个数组是否是另一个数组的子集
        const isSubset = (array1, array2) => array2.every((element) => array1.includes(element));
        console.log(isSubset([1, 2, 3, 4, 5, 6, 7], [5, 7, 6])); // true
        console.log(isSubset([1, 2, 3, 4, 5, 6, 7], [5, 8, 7])); // false
    </script>
</body>

</html>